<template>
    <div class="app-container">
        <wms-form v-model:query-params="queryParams" :form-list="formList" @query="getList" label-width="88px"
            @export="handleExport">
        </wms-form>

        <wms-table class="table-click" :loading="loading" :data-list="wcsTaskList" :column="column" :columnResize="true"
            :pageInfo="queryParams" @get-list="getList" @selection-change="handleSelectionChange" />
    </div>
</template>

<script setup name="WcsTask">
import WmsTable from '@/components/WmsTable/index.vue'
import WmsForm from '@/components/WmsForm/index.vue'
import { data, column, formList } from './index.js'
import { listToWcsTask, getToWcsTask } from "@/api/wms/toWcsTask";
import { ref, reactive, getCurrentInstance, onMounted } from "vue";

const { proxy } = getCurrentInstance();
const queryParams = reactive(data.queryParams);

const wcsTaskList = ref([]);

const loading = ref(true);

const ids = ref([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const title = ref("");

// const dateRange = ref([]);

/** 查询搬送指令列表 */
function getList() {
    loading.value = true;
    listToWcsTask(queryParams).then(response => {
        wcsTaskList.value = response.rows;
        total.value = response.total;
        loading.value = false;
    });
}

/** 搜索按钮操作 */
function handleQuery() {
    queryParams.pageNum = 1;
    getList();
}

/** 重置按钮操作 */
function resetQuery() {
    // dateRange = [];
    proxy.resetForm("toWcsTaskRef");
    handleQuery();
}

// 多选框选中数据
function handleSelectionChange(selection) {
    ids.value = selection.map(item => item.trkId);
    single.value = selection.length != 1;
    multiple.value = !selection.length;
}

/** 导出按钮操作 */
function handleExport() {
    proxy.download('wms/toWcsTask/export', {
        ...queryParams
    }, `toWcsTask_${new Date().getTime()}.xlsx`)
}

getList();
</script>
